package com.ljm.common.constants;

import com.ljm.common.util.IPUtils;
import org.slf4j.MDC;

/**
 * @Auther: ChenHuaMing
 * @Date: 2019/10/21 11:37
 * @Description: 日志打印常量标识
 */
public class LogConstants {
    private LogConstants(){}

    /**
     * traceId
     */
    public static final ThreadLocal<String> trackIdThreadLocal=new InheritableThreadLocal<>();
    /**
     * 客户端ip
     */
    public static final ThreadLocal<String> ipThreadLocal=new InheritableThreadLocal<>();

    /**
     * 调用链id
     */
    public static final String LOG_TRACE_ID="traceId";
    /**
     * 服务器ip
     */
    public static final String LOG_IP="ip";

    public static void intMdc(){
        MDC.put(LogConstants.LOG_TRACE_ID, "startMain");
        MDC.put(LogConstants.LOG_IP, IPUtils.getLocalIpAddress());
    }
}
